#include "State.h"
#include "Commodity.h"
#include <string>
#include <iostream>
#include <map>
using namespace std;

State::State(void)
{
}

State::State(string state_name)
{
	name = state_name;
}

string State::get_name(void)
{
	return name;
}

void State::set_local_market(map<string,float>* global_market)
{
	// Iterate through the global market and set a local market map<string, float>
	int count = 0;
	cout << "Setting local market for: " << get_name() << endl;
	for (auto it = global_market->begin(); it!= global_market->end(); ++it)
	{
		
		cout << "  GLOBAL MARKET: " << it->first << " - " << it->second << endl;
		Commodity new_commodity = Commodity::Commodity(it->first, it->second);
		cout << "  LOCAL  MARKET: " << new_commodity.get_name()  << " - " << new_commodity.get_price() << endl << endl << endl;
		local_market[count] = new_commodity;
		count++;
		// Need to initialise 
	}
	
}

void State::print_market(void)
{
	for (int i = 0; i < 8; i++ )
	{	
		cout << "Product: " << local_market[i].get_name() << "   - Price: " << local_market[i].get_price() << endl;
	}
}

State::~State(void)
{
}

